package com.SweetWhite.UserManagement.model.controller;

import java.io.File;
import java.io.IOException;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import com.SweetWhite.UserManagement.model.bean.Hero_User;



@Controller
public class IconController {
@Autowired
private HttpServletRequest req;
@RequestMapping("iconUpload")
public void iconUpload(@RequestParam("icon") MultipartFile icon) throws IllegalStateException, IOException {
	String filepath=req.getSession().getServletContext().getRealPath("fileUpload");
	Hero_User hu =(Hero_User) req.getSession().getAttribute("user");
	String iconName=hu.getNo()+".png";
	icon.transferTo(new File(filepath+"/icon/"+iconName));
}
}
